jQuery scroll事件实现监控滚动条分页示例 |
您所在的位置:网站首页 › jquery scroll › jQuery scroll事件实现监控滚动条分页示例 |
这篇文章主要介绍了 jQuery scroll 事件实现监控滚动条分页简单示例 , 使用 ajax 加 载 , 同时介绍了 (document).height() 与 $(window).height() 的区别 , 需要的朋友可以参考下 scroll 事件适用于 window 对象,但也可滚动 iframe 框架与 CSS overflow 属性设置为 scroll 的 元素。
代码如下 :
$(document).ready(function () { // 本人习惯这样写了
$(window).scroll(function () { //$(window).scrollTop() 这个方法是当前滚动条滚动的距离
//$(window).height() 获取当前窗体的高度
//$(document).height() 获取当前文档的高度
var bot = 50; //bot 是底部距离的高度
if ((bot + $(window).scrollTop()) >= ($(document).height() - $(window). height())) { // 当底部基本距离 + 滚动的高度〉 = 文档的高度 - 窗体的高度时;
// 我们需要去异步加载数据了
$.getJSON("url", { page: "2" }, function (str) { alert(str); }); } }); }); 注意: (window).height() 和 (document).height() 的区别
jQuery(window).height() 代表了当前可见区域的大小,而 jQuery(document).height() 则 代表了整个文档的高度,可视具体情况使用 . |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |